package com.example.gongj;

import java.io.*;

/**
 * 使用缓存流复制文件
 */
public class FileCopyDemo2 {
    public static void main(String[] args) throws Exception {
        long startTime = System.currentTimeMillis();
        //创建流对象
        try(BufferedInputStream bis = new BufferedInputStream(new FileInputStream("D:\\安装包\\SecureCRT72.zip"));
            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("D:\\安装包\\SecureCRT744442.zip"));)
        {
            // 读写数据
            int len = 0;
            byte[] b = new byte[1024];
            while ((len = bis.read(b)) != -1){
                bos.write(b,0,len);
            }
        }catch (IOException e){
            e.printStackTrace();
        }

        long endTime = System.currentTimeMillis();
        System.out.println("缓冲流复制时间:"+(endTime - startTime)+" 毫秒");
    }
}
